package com.blog.wu.myblog.activemq;

import com.blog.wu.myblog.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * @Author wuyanshen
 * @Date 2018-12-25 1:17 PM
 * @Discription springboot整合后的 生产者
 */

@Component
public class MQProducer extends BaseService {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;
    @Autowired
    private Queue queue;

//    @Scheduled(cron = "0/3 * * * * ?")
    public void send() {
        String message = System.currentTimeMillis()+"-----测试消息";
        logger.info("我是生产者，向队列发送消息：{}",message);
        jmsMessagingTemplate.convertAndSend(queue,message);

    }
}
